const nodemailer = require("nodemailer");

let transporter = nodemailer.createTransport({
  service: "QQ",
  port: 465,
  secure: true,
  auth: {
    user: "1029708622@qq.com",
    pass: "mcawyzchkvpcbajb",
  },
});

let mailOptions = {
  from: "沈嘉宁🌲👻 <1029708622@qq.com>", // 发送者昵称和地址
  to: "1029708622@qq.com", // 接收者的邮箱地址
  subject: "您收到新的意见啦~", // 邮件主题
  html: "",
};

async function sendEmail(content, title) {
  if (title) {
    mailOptions.subject = title;
  }
  mailOptions.html = `
  <div style="font-size: 14px; font-weight: bold;">
    ${content}
  </div>
  `;
  transporter.sendMail(mailOptions, (error, info) => {
    if (error) return;
    console.log("邮件发送成功", info.messageId);
  });
}

module.exports = sendEmail;
